#include "fxcc/yml/Serializer.h"
#include "fxcc/core/graph/common/Texture2DJack.h"

using namespace YAML;
using namespace fxcc::yml;
using namespace fxcc::graph::common;

template<>
void Serializer::Encode<fxcc::graph::common::ImageMipmap::MipMapData>(YAML::Node& node, const fxcc::graph::common::ImageMipmap::MipMapData& inst)
{

	SetVariable<int>(node, "m_Width", inst.m_Width);
	SetVariable<int>(node, "m_Height", inst.m_Height);
	SetVariable<int>(node, "m_NrComponent", inst.m_NrComponent);
	SetVariable<int>(node, "m_HDR", inst.m_HDR);
}


template<>
bool Serializer::Decode<fxcc::graph::common::ImageMipmap::MipMapData>(const YAML::Node& node, fxcc::graph::common::ImageMipmap::MipMapData& inst)
{

	GetVariable<int>(node, "m_Width", inst.m_Width);
	GetVariable<int>(node, "m_Height", inst.m_Height);
	GetVariable<int>(node, "m_NrComponent", inst.m_NrComponent);
	GetVariable<int>(node, "m_HDR", inst.m_HDR);
	return true;

}

template<>
void Serializer::Encode<Texture2DJack::Desc>(YAML::Node& node, const Texture2DJack::Desc& inst)
{
	SetVariable<glm::vec2>(node, "m_TexStartPos", inst.m_TexStartPos);
	SetVariable<glm::vec2>(node, "m_TexOffsetSize", inst.m_TexOffsetSize);
	SetVariable<fxcc::graph::common::ImageMipmap::Desc>(node, "m_WICConfig", inst.m_WICConfig);
	SetVariable<std::string>(node, "m_DDSPath", inst.m_DDSPath);
	SetVariable<fxcc::graph::common::ImageMipmap::MipMapData>(node, "m_MipmapData", inst.m_MipmapData);
	SetVariableEnum<fxcc::graph::common::SamplerType>(node, "m_SampleType", inst.m_SampleType);
	SetVariableEnum<Texture2DJack::Desc::Type>(node, "m_Type", inst.m_Type);
}


template<>
bool Serializer::Decode<Texture2DJack::Desc>(const YAML::Node& node, Texture2DJack::Desc& inst)
{
	GetVariable<glm::vec2>(node, "m_TexStartPos", inst.m_TexStartPos);
	GetVariable<glm::vec2>(node, "m_TexOffsetSize", inst.m_TexOffsetSize);
	GetVariable<fxcc::graph::common::ImageMipmap::Desc>(node, "m_WICConfig", inst.m_WICConfig);
	GetVariable<std::string>(node, "m_DDSPath", inst.m_DDSPath);
	GetVariable<fxcc::graph::common::ImageMipmap::MipMapData>(node, "m_MipmapData", inst.m_MipmapData);
	GetVariableEnum<fxcc::graph::common::SamplerType>(node, "m_SampleType", inst.m_SampleType);
	GetVariableEnum<Texture2DJack::Desc::Type>(node, "m_Type", inst.m_Type);

	return true;

}

template<>
void Serializer::Encode<Texture2DJack>(YAML::Node& node, const Texture2DJack& inst)
{
	SetVariable<Texture2DJack::Desc>(node, "m_Desc", inst.m_Desc);
}


template<>
bool Serializer::Decode<Texture2DJack>(const YAML::Node& node, Texture2DJack& inst)
{
	GetVariable<Texture2DJack::Desc>(node, "m_Desc", inst.m_Desc);
	return true;

}